<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>画图案例02</title>
    <script src="echarts.js"></script>
</head>

<body>
    <div id="main" style="width: 100%; height: 300px;"></div>
    <script type="text/javascript">
        var mychart = echarts.init(document.getElementById('main'));
        var option = {
            title: {
                text: "巴啦啦能量",
                link: 'https://www.baidu.com',
                target: 'self',
                textStyle: {
                    color: '#F4606C',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
                subtextStyle: {
                    color: '#D1BA74',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
                subtext: "小魔仙全身变",
                sublink: 'https://movie.douban.com/photos/photo/2167396555/',
                subtarget: 'self',
                textAlign: 'auto',
                // 分别设置四个方向的内边距
                padding: [
                    5, // 上
                    10, // 右
                    5, // 下
                    10, // 左
                ]
            },


            // 径向渐变，前三个参数分别是圆心 x, y 和半径，取值同线性渐变--改变的是图表的颜色
            color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                        offset: 0,
                        color: '#ECAD9E' // 0% 处的颜色
                    }, {
                        offset: 0.5,
                        color: '#D1BA74'
                    },

                    {
                        offset: 1,
                        color: '#19CAAD' // 100% 处的颜色
                    }
                ],
                global: false // 缺省为 false
            },


            backgroundColor: '#D6D5B7',

            legend: {
                data: ['数量'],
                top: '5%',
                textStyle: {
                    color: '#F4606C',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
            },
            xAxis: {
                type: 'category',
                data: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天']

            },
            yAxis: {
                type: 'value'
            },
            series: [{
                name: '数量',
                data: [200, 400, 600, 1400, 1000, 100, 1400, ],
                type: 'effectScatter'

            }]

        };
        var res = [
            [111, 222, 333, 444, 555, 666, 777],
            [111, 262, 333, 444, 555, 666, 777],
            [1, 222, 333, 454, 555, 666, 777],
            [11, 222, 733, 444, 555, 666, 777],


        ];

        // 开始定时器
        setInterval(getList, 1000);

        function getList() {
            var i = parseInt(Math.random() * res.length);
            option.series[0].data = res[i];
            mychart.setOption(option);
        };
        getList();
    </script>
    <div id="main2" style="width:100%; height: 300px;"></div>
    <script type="text/javascript">
        var mychart2 = echarts.init(document.getElementById('main2'));
        var option2 = {
            title: {
                text: "巴啦啦能量",
                link: 'https://www.baidu.com',
                target: 'self',
                textStyle: {
                    color: '#F4606C',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
                subtextStyle: {
                    color: '#D1BA74',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
                subtext: "小魔仙全身变",
                sublink: 'https://movie.douban.com/photos/photo/2167396555/',
                subtarget: 'self',
                textAlign: 'auto',
                // 分别设置四个方向的内边距
                padding: [
                    5, // 上
                    10, // 右
                    5, // 下
                    10, // 左
                ]
            },


            // 径向渐变，前三个参数分别是圆心 x, y 和半径，取值同线性渐变--改变的是图表的颜色
            color: {
                type: 'linear',
                x: 0,
                y: 0,
                x2: 0,
                y2: 1,
                colorStops: [{
                        offset: 0,
                        color: '#ECAD9E' // 0% 处的颜色
                    },

                    {
                        offset: 1,
                        color: '#D1BA74' // 100% 处的颜色
                    }
                ],
                global: false // 缺省为 false
            },


            backgroundColor: '#F4606C',

            legend: {
                data: ['数量'],
                top: '5%',
                textStyle: {
                    color: '#D6D5B7',
                    fontFamily: '幼圆',
                    fontWeight: 'bolder',
                    fontSize: 20,
                },
            },
            xAxis: {
                type: 'category',
                data: ['星期一', '星期二', '星期三', '星期四', '星期五', '星期六', '星期天']

            },
            yAxis: {
                type: 'value'
            },
            series: [{
                name: '数量',
                data: [200, 400, 600, 1400, 1000, 100, 1400, ],
                type: 'bar'

            }]

        };
        mychart2.setOption(option2);
        window.onresize = function() {
            mychart2.resize();
            mychart.resize();
        };
    </script>

</body>

</html>